package com.project.service.impl;

import com.project.bean.BookBean;
import com.project.mapper.IBookMapper;
import com.project.mapper.ISpeakMapper;
import com.project.service.IBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class BookServiceImpl  implements IBookService {
    @Autowired
    private IBookMapper mapper;
    @Autowired
    private ISpeakMapper mappers;
    @Override
    public List<BookBean> findAll() {
        return mapper.findAll();
    }

    @Override
    public BookBean findById(int id) {
        BookBean book =  mapper.findById(id);
        book.setSpeaks(mappers.findByBook(id));
        return book;
    }
}
